﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;

/// <summary>
/// Summary description for CustomerDAL
/// </summary>
public class CustomerDAL
{
    private DatabaseAccess dba = new DatabaseAccess();
    public CustomerDAL()
    {
        //
        // TODO: Add constructor logic here
        //
    }
    public bool InsertCustomer(Customer objCus)
    {
        SqlParameter[] paramList = new SqlParameter[8];
        paramList[0] = new SqlParameter("@cus_firstname", SqlDbType.VarChar, 50);
        paramList[0].Value = objCus.Firstname;
        paramList[1] = new SqlParameter("@cus_lastname", SqlDbType.VarChar, 50);
        paramList[1].Value = objCus.Lastname;
        paramList[2] = new SqlParameter("@cus_dateOfbirth", SqlDbType.DateTime);
        paramList[2].Value = objCus.Birthday;
        paramList[3] = new SqlParameter("@cus_gender", SqlDbType.Bit);
        paramList[3].Value = objCus.Gender;
        paramList[4] = new SqlParameter("@cus_address", SqlDbType.NVarChar, 250);
        paramList[4].Value = objCus.Address;
        paramList[5] = new SqlParameter("@cus_email", SqlDbType.VarChar, 50);
        paramList[5].Value = objCus.Email;
        paramList[6] = new SqlParameter("@cus_password", SqlDbType.VarChar, 20);
        paramList[6].Value = objCus.Password;
        paramList[7] = new SqlParameter("@cus_phone", SqlDbType.VarChar, 20);
        paramList[7].Value = objCus.Phone;
        return dba.executeUpdate("proc_insertCustomer", paramList);
    }

    public DataTable GetCustomerByEmail(String _email, String _password)
    {
        SqlParameter[] paramList = new SqlParameter[2];
        paramList[0] = new SqlParameter("@cus_email", SqlDbType.VarChar, 50);
        paramList[0].Value = _email;

        paramList[1] = new SqlParameter("@cus_password", SqlDbType.VarChar, 20);
        paramList[1].Value = _password;

        return dba.executeSelect("proc_getCustomerByEmail", paramList);
    }

}
